---@class Battle.AToBRandomPathEffect :Battle.EffectBase
local AToBRandomPathEffect = Battle.CreateClass("AToBRandomPathEffect",Battle.EffectBase)
Battle.AToBRandomPathEffect = AToBRandomPathEffect

---@param buff Battle.Buffer
function AToBRandomPathEffect:BindBuff(buff)
    self.startPos = Vector3.New()
    self.endPos = Vector3.New()
    self.startPos:SetV(buff.sourceSender:GetHitPos())
    self.endPos:SetV(buff:GetTarget():GetHitPos())
    self.speed = 5
    self.moveTime = Vector3.Distance(self.startPos,self.endPos)/self.speed
end

function AToBRandomPathEffect:OnLoadFinished()
    self:SetPos(self.startPos.x,self.startPos.y,self.startPos.z)
end
function AToBRandomPathEffect:Update(dt)
    Battle.EffectBase.Update(self,dt)
    local t = self.curTime/self.moveTime
    Vector3.Lerp2(self.startPos,self.endPos,t,self.pos)
    self:SetPos(self.pos.x,self.pos.y,self.pos.z)
    if t >= 1 then
        self:Die()
    end
end
